self.onmessage = (e) => {
  console.log("worker", e);
  let arr = longFun();
  self.postMessage(arr);
};
function longFun() {
  console.log("执行长任务");
  let i = 0;
  const start = performance.now();
  // 5秒内不停执行 i++ 操作，实现长任务效果
  while (performance.now() - start <= 5000) {
    i++;
  }
  return i;
}
